<%@page import="com.lyb.bean.GaoJian"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>分配稿件</title>
<style>
.header{
float:right;
font-size:16px;
}
</style>
</head>
<body>
<div class="header"><a href="/zaixiantougao/index.jsp">退出登录</a></div>
<ul>

<li><a href="gaojianfenpei.jsp">稿件分配</a></li>
<li><a href="guanliyonghu.jsp">管理用户</a></li>
<li><a href="guanligaojian.jsp">管理稿件</a></li>

</ul>
<%try {
	Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
String url = "jdbc:mysql://localhost:3306/tougaoxitong?useUnicode=true&characterEncoding=UTF-8";
String user = "root";
String mysqlpassword = "";


Connection conn = DriverManager.getConnection(url,user,mysqlpassword);

	
//	查询
	Statement stmt = conn.createStatement();
	String sql = "select * from gaojian where bianjizhe='无'";
	System.out.print(sql);
	ResultSet rs = stmt.executeQuery(sql);
	ArrayList<GaoJian> gaojianList =new ArrayList<GaoJian>(); 
	while(rs.next()){
		GaoJian gaojian = new GaoJian();
		int id = rs.getInt("id");
		String title = rs.getString("title");
		String content = rs.getString("content");
		String zhushi = rs.getString("zhushi");
		String bianjizhe = rs.getString("bianjizhe");
		String zuozhe = rs.getString("zuozhe");
		String type = rs.getString("type");
		String status =rs.getString("status");
		gaojian.setId(id);
		gaojian.setStatus(status);
		gaojian.setTitle(title);
		gaojian.setContent(content);
		gaojian.setZhushi(zhushi);
		gaojian.setBianjizhe(bianjizhe);
		gaojian.setZouzhe(zuozhe);
		gaojian.setType(type);
		gaojianList.add(gaojian);
	}
	System.out.print(gaojianList.size());
	for(int i=0;i<gaojianList.size();i++){
		GaoJian gaojian = gaojianList.get(i);
%>

<ul>
<li id="li<%=i%>"><%=gaojian.getTitle()%>文/<%=gaojian.getZouzhe() %>[<%=gaojian.getType() %>](<%=gaojian.getStatus() %>)
<form action="fenpeigei?id=<%= gaojian.getId()%>" method="post">将这篇文章分配给：<input type="text" name="bianjizhe">
<input type="submit" value="提交">
</form></li>
<div id="content<%=i%>"><%=gaojian.getContent() %>
注释：<%=gaojian.getZhushi() %>
</div>
</ul>
<style type="text/css">

#content<%=i%>{
display:none;
}
li{

cursor:pointer;
}
</style>
				<script type="text/javascript">
var li<%=i%> = document.getElementById("li<%=i%>");
var content<%=i%> = document.getElementById("content<%=i%>");
console.log(li<%=i%>);
li<%=i%>.addEventListener("click",function(){
	if(content<%=i%>.style.display=="none"){
	content<%=i%>.style.display = "block";
	}else{
content<%=i%>.style.display = "none";}
})
</script>
<% }%>

</body>
</html>